home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / copyd11.zip / HARDSET.ASM < prev    next >
Assembly Source File  |  1991-03-01  |  1KB  |  77 lines

  1. ; routines to handle hardware errors.
  2.  
  3. ; hardset installs a hardware error routine and sets the global
  4. ; variable _Hard_error to FALSE (0)
  5.  
  6. ; hardclear deinstalls the hardware error routine
  7.  
  8. ; hardhandle receives control if an error occurs.  It sets _Hard_error
  9. ; to 1 + error code and tells MS-DOS 2 to ignore the error, MS-DOS 3+ to
  10. ; fail the DOS call.
  11.  
  12. TRUE    equ    1
  13. FALSE    equ    0
  14.  
  15.     DGROUP    GROUP _DATA,_BSS
  16.  
  17. _BSS    segment word public 'bss'
  18. _BSS    ends
  19.  
  20. _DATA    segment word public 'data'
  21. old24    dd    ?        ; save old int 24 address here
  22. _DATA    ends
  23.  
  24.     extrn    _Hard_error:word
  25.     extrn    _Fail_ignore:word
  26.     public    _hardset,_hardclear
  27.  
  28. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  29.     ASSUME    CS:_TEXT,DS:DGROUP
  30.  
  31. _hardset proc    far
  32.  
  33.     mov    DGROUP:_Hard_error,FALSE    ; set no error
  34.  
  35.     mov    ax,3524h        ; get interrupt vector
  36.     int    21h
  37.     mov    word ptr old24,bx    ; old vector is in ES:BX
  38.     mov    word ptr old24+2,es
  39.     mov    ax,2524h        ; set interrupt vector
  40.     mov    dx,offset hardhandle
  41.     push    ds
  42.     push    cs
  43.     pop    ds
  44.     int    21h
  45.     pop    ds
  46.  
  47.     ret
  48. _hardset endp
  49.  
  50. _hardclear proc far
  51.  
  52.     mov    ax,2524h        ; set interrupt vector
  53.     push    ds
  54.     lds    dx,old24        ; restore old vector
  55.     int    21h
  56.     pop    ds
  57.  
  58.     ret
  59. _hardclear endp
  60.  
  61. hardhandle proc    far
  62.  
  63.     push    ds
  64.     mov    ax,SEG DGROUP
  65.     mov    ds,ax
  66.     and    di,7fh            ; error code in low byte
  67.     inc    di            ; return 1+error so non-zero if error
  68.     mov    DGROUP:_Hard_error,di
  69.     mov    ax,DGROUP:_Fail_ignore    ; 0 for DOS-2 (ignore), else 3 (fail)
  70.     pop    ds
  71.     iret
  72.  
  73. hardhandle endp
  74.  
  75. _TEXT    ends
  76.     end
  77.